//
//  SMRTImageManager.m
//  Portable Traffic Signal Assistor
//
//  Created by Hao Xu on 6/4/12.
//  Copyright (c) 2012 TTU. All rights reserved.
//

#import "SMRTImageManager.h"

@implementation SMRTImageManager

+ (UIImageView *) getDirectionImageViewByMovement:(NSString *)movement
{
    UIImageView *imageView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@.png",movement]]] autorelease];
    //CGRect imageViewRect = CGRectMake(0.0,  0.0, 320 , 40);
    ////        titleImage.frame = imageViewRect;
    ////        titleImage.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
    NSRange range = [movement rangeOfString:@"B"];
    
    NSString *imageName=nil;
    if (range.location != NSNotFound) {
        
        // found a colon
        if (range.location + 1 < [movement length]) {
            NSString *directionName =[movement substringToIndex:range.location] ;
            NSString *movementName=[movement substringFromIndex:(range.location + 1)];
            imageName=[NSString stringWithFormat:@"%@%@.png",directionName,movementName];
            return nil;
        }else {
            return nil;
        }
    }
    return imageView;
}

@end
